5 6 7 8 9 10
The statement
FOR I = 5 TO 10
says that I
will get the
values 5 through 10.
Each value will be PRINT
ed.
The semicolon after the I
in the PRINT
statement keeps the output
on one line.
(This is a picky detail, but useful for presenting compact examples.)
In general, the FOR
statement looks like this:
FOR counter = startingValue TO endingValue loopBody NEXT counter
Remember that the term syntax
means "the grammar of a program."
Syntax tells you how a program (or part of a program) should
look.
Here are some rules about FOR
statements:
NEXT
.)These rules look worse than they are. A few examples will make them clear. Here is a correct program:
' Counting Loop ' LET START = 1 LET FINISH = 5 FOR I = START TO FINISH PRINT I; NEXT I END
Find at least 4 rules from the above list that this program illustrates.